{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "using DifferentialEquations\n",
    "using PyPlot\n",
    "using ReactionMechanismSimulator"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "phaseDict = readinput(\"../src/testing/liquid_phase.rms\") #load mechanism dictionary"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "spcs = phaseDict[\"phase\"][\"Species\"]; #mechanism dictionaries index:  phaseDict[phasename][\"Species\" or \"Reactions\"]\n",
    "rxns = phaseDict[\"phase\"][\"Reactions\"];"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "solv = Solvent(\"octane\",RiedelViscosity(-98.805,3905.5,14.103,-2.5112e-5,2.0));"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "liq = IdealDiluteSolution(spcs,rxns,solv;name=\"phase\",diffusionlimited=true); #Define the phase (how species thermodynamic and kinetic properties calculated)\n",
    "initialconds = Dict([\"T\"=>450.0,\"P\"=>1e5,\"V\"=>1.0e-6*1e6,\"octane\"=>6.154e-3*1e6,\"oxygen\"=>4.953e-6*1e6]); #Set simulation Initial Temp and Pressure\n",
    "domain,y0 = ConstantTVDomain(phase=liq,initialconds=initialconds,\n",
    "    constantspecies=[\"oxygen\"]); #Define the domain (encodes how system thermodynamic properties calculated)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "react = Reactor(domain,y0,(0.0,140000.01)); #Create the reactor object"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "sol = solve(react.ode,CVODE_BDF(),abstol=1e-20,reltol=1e-8); #solve the ode associated with the reactor"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bsol = Simulation(sol,domain);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plotmolefractions(bsol,140000.0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "getfluxdiagram(bsol,100000.0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "@webio": {
   "lastCommId": null,
   "lastKernelId": null
  },
  "kernelspec": {
   "display_name": "Julia 1.1.0",
   "language": "julia",
   "name": "julia-1.1"
  },
  "language_info": {
   "file_extension": ".jl",
   "mimetype": "application/julia",
   "name": "julia",
   "version": "1.1.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
